<template>
    <div class="box">
        <el-form ref="form" size="mini" :model="form" label-width="80px">
        
        
       <!-- 号码 -->
        <el-form-item label="号码">
            <div v-for="(item,index) in form.mainInfo" :key="index" class="sysItem">
              <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.boolType"  style="width:80px;margin-right:10px">
                    <el-option label="AND" value=1></el-option>
                    <el-option label="OR" value=2></el-option>
                    <el-option label="NOT" value=3></el-option>
            </el-select>
             <el-select v-if="!item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:300px;margin-bottom:6px">
                    <el-option label="申请号" value="application_number"></el-option>
                    <el-option label="公开(公告)号" value="public_number"></el-option>
                    <el-option label="IPC主分类号" value="ipc_main"></el-option>
                    <el-option label="专利类型" value="patent_type"></el-option>
            </el-select>

             <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:210px;margin-bottom:6px">
                    <el-option label="申请号" value="application_number"></el-option>
                    <el-option label="公开(公告)号" value="public_number"></el-option>
                    <el-option label="IPC主分类号" value="ipc_main"></el-option>
                    <el-option label="专利类型" value="patent_type"></el-option>
            </el-select>


            <el-input class="inputView" v-model="item.value"></el-input>
             <i @click="addNum" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="!item.hasOwnProperty('notFrist')" class="el-icon-circle-plus-outline"></i>
            <i @click="deltNum(index)" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="item.hasOwnProperty('notFrist')" class="el-icon-remove-outline"></i>
           </div>
           
        </el-form-item>
        
        <!-- 名称和地址 -->
        <el-form-item label="名称和地址">
            <div v-for="(item,index) in form.nameAndAddress" :key="index" class="sysItem">
              <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.boolType"  style="width:80px;margin-right:10px">
                    <el-option label="AND" value=1></el-option>
                    <el-option label="OR" value=2></el-option>
                    <el-option label="NOT" value=3></el-option>
            </el-select>
             <el-select v-if="!item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:300px;margin-bottom:6px">
                    <el-option label="申请人" value="applicants"></el-option>
                    <el-option label="发明人" value="inventors"></el-option>
                    <el-option label="当前权利人" value="assignees"></el-option>
                    <el-option label="代理机构" value="agency"></el-option>
            </el-select>

             <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:210px;margin-bottom:6px">
                   <el-option label="申请人" value="applicants"></el-option>
                    <el-option label="发明人" value="inventors"></el-option>
                    <el-option label="当前权利人" value="assignees"></el-option>
                    <el-option label="代理机构" value="agency"></el-option>
            </el-select>


            <el-input class="inputView" v-model="item.value"></el-input>
             <i @click="addName" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="!item.hasOwnProperty('notFrist')" class="el-icon-circle-plus-outline"></i>
            <i @click="deltNameAndAddress(index)" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="item.hasOwnProperty('notFrist')" class="el-icon-remove-outline"></i>
           </div>
           
        </el-form-item>

        <!-- 日期 -->
        
        <el-form-item label="日期">
            <div class="sysItem">
                <el-select v-model="form.dateInfo.sign" placeholder="--请选择--" style="width:210px;margin-bottom:6px">
                   <el-option label="申请日" value="application_date"></el-option>
                    <el-option label="申请年" value="public_year"></el-option>
                    <el-option label="公开(公告)日" value="public_date"></el-option>
                    <el-option label="公开月" value="public_month"></el-option>
                     <el-option label="公开年" value="public_year"></el-option>
               </el-select>

               <el-select v-model="form.dateInfo.value" placeholder="--请选择--" style="width:210px;margin-bottom:6px;margin-left:10px">
                   <el-option label="某时间段" value="1"></el-option>
                   <el-option label="某时间以前" value="2"></el-option>
                   <el-option label="某时间以后" value="3"></el-option>
                   <el-option label="某年(月,日)" value="4"></el-option>
                   
               </el-select>

                <el-date-picker
                    style="margin-left:10px"
                    v-model="form.dateInfo.value1"
                    align="right"
                    type="date"
                    placeholder="选择日期"
                    :picker-options="pickerOptions">
                    </el-date-picker>

                            <el-date-picker
                            style="margin-left:10px"
                v-model="form.dateInfo.value2"
                align="right"
                type="date"
                placeholder="选择日期"
                :picker-options="pickerOptions">
                </el-date-picker>
            </div>
           
        </el-form-item>



        <!-- 法律信息 -->
        
        <el-form-item label="法律信息">
            <div v-for="(item,index) in form.legalInfo" :key="index" class="sysItem">
              <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.boolType"  style="width:80px;margin-right:10px">
                    <el-option label="AND" value=1></el-option>
                    <el-option label="OR" value=2></el-option>
                    <el-option label="NOT" value=3></el-option>
            </el-select>
             <el-select v-if="!item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:300px;margin-bottom:6px">
                    <el-option label="法律状态" value="legal_status"></el-option>
                    <el-option label="许可次数" value="licensed_count"></el-option>
                    <el-option label="转让次数" value="transfered_count"></el-option>
                    <el-option label="质押次数" value="pledges_count"></el-option>

                    <el-option label="被引用次数" value="cited_count"></el-option>
                    <el-option label="专利被提起无效次数" value="patent_invalidation_count"></el-option>
            </el-select>

             <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:210px;margin-bottom:6px">
                    <el-option label="法律状态" value="legal_status"></el-option>
                    <el-option label="许可次数" value="licensed_count"></el-option>
                    <el-option label="转让次数" value="transfered_count"></el-option>
                    <el-option label="质押次数" value="pledges_count"></el-option>

                    <el-option label="被引用次数" value="cited_count"></el-option>
                    <el-option label="专利被提起无效次数" value="patent_invalidation_count"></el-option>
            </el-select>


            <el-input class="inputView" v-model="item.value"></el-input>
             <i @click="addLegal" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="!item.hasOwnProperty('notFrist')" class="el-icon-circle-plus-outline"></i>
            <i @click="deltLegal(index)" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="item.hasOwnProperty('notFrist')" class="el-icon-remove-outline"></i>
           </div>
           
        </el-form-item>

        <!-- 是否其他法律状态 -->

         <el-form-item label="其他法律状态">
            <div v-for="(item,index) in form.isLegal" :key="index" class="sysItem">
              <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.boolType"  style="width:80px;margin-right:10px">
                    <el-option label="AND" value=1></el-option>
                    <el-option label="OR" value=2></el-option>
                    <el-option label="NOT" value=3></el-option>
            </el-select>
             <el-select v-if="!item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:300px;margin-bottom:6px">
                    <el-option label="是否专利被宣告无效" value="is_patent_invalidation"></el-option>
                    <el-option label="是否涉诉专利" value="has_lawsuit"></el-option>
                    <el-option label="是否复审" value="has_recheck"></el-option>

                    
            </el-select>

             <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:210px;margin-bottom:6px">
                     <el-option label="是否专利被宣告无效" value="is_patent_invalidation"></el-option>
                    <el-option label="是否涉诉专利" value="has_lawsuit"></el-option>
                    <el-option label="是否复审" value="has_recheck"></el-option>
                   
            </el-select>




             <el-select class="inputView" placeholder="--请选择--">
                     <el-option label="是" value="1"></el-option>
                    <el-option label="否" value="0"></el-option>
                   
            </el-select>
             <i @click="addIsLegal" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="!item.hasOwnProperty('notFrist')" class="el-icon-circle-plus-outline"></i>
            <i @click="deltIsLegal(index)" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="item.hasOwnProperty('notFrist')" class="el-icon-remove-outline"></i>
           </div>
           
        </el-form-item>

       <!-- 专利奖 -->

        <el-form-item label="专利奖">
            <div v-for="(item,index) in form.patentAward" :key="index" class="sysItem">
              <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.boolType"  style="width:80px;margin-right:10px">
                    <el-option label="AND" value=1></el-option>
                    <el-option label="OR" value=2></el-option>
                    <el-option label="NOT" value=3></el-option>
            </el-select>
             <el-select v-if="!item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:300px;margin-bottom:6px">
                    <el-option label="中国专利奖项" value="reward_name"></el-option>
                    <el-option label="中国专利奖等级" value="reward_level"></el-option>
                    <el-option label="地方专利奖项" value="region_reward_name"></el-option>
                   
            </el-select>

             <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:210px;margin-bottom:6px">
                   <el-option label="中国专利奖项" value="reward_name"></el-option>
                    <el-option label="中国专利奖等级" value="reward_level"></el-option>
                    <el-option label="地方专利奖项" value="region_reward_name"></el-option>
            </el-select>


            <el-input class="inputView" v-model="item.value"></el-input>
             <i @click="addPatentAward" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="!item.hasOwnProperty('notFrist')" class="el-icon-circle-plus-outline"></i>
            <i @click="deltPatentAward(index)" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="item.hasOwnProperty('notFrist')" class="el-icon-remove-outline"></i>
           </div>
           
        </el-form-item>

        <!-- 专利价值 -->
         <el-form-item label="专利价值">
            <div v-for="(item,index) in form.patentValue" :key="index" class="sysItem">
              <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.boolType"  style="width:80px;margin-right:10px">
                    <el-option label="AND" value=1></el-option>
                    <el-option label="OR" value=2></el-option>
                    <el-option label="NOT" value=3></el-option>
            </el-select>
             <el-select v-if="!item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:300px;margin-bottom:6px">
                    <el-option label="是否高价值专利" value="is_high_cost"></el-option>
                    <el-option label="高价值专利要素-战略性新兴产业" value="is_strategic_emerging"></el-option>
                    <el-option label="高价值专利要素—是否海外同族" value="has_abroad_family"></el-option>

                    <el-option label="高价值专利要素-发明维持超过10年" value="is_duration_ten_year"></el-option>
                    <el-option label="高价值专利要素-较高质押融资金额" value="is_high_inventory"></el-option>
                    <el-option label="高价值专利要素-获得国家科学技术奖或中国专利奖" value="has_reward"></el-option>

                    
            </el-select>

             <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:210px;margin-bottom:6px">
                    <el-option label="是否高价值专利" value="is_high_cost"></el-option>
                    <el-option label="高价值专利要素-战略性新兴产业" value="is_strategic_emerging"></el-option>
                    <el-option label="高价值专利要素—是否海外同族" value="has_abroad_family"></el-option>

                    <el-option label="高价值专利要素-发明维持超过10年" value="is_duration_ten_year"></el-option>
                    <el-option label="高价值专利要素-较高质押融资金额" value="is_high_inventory"></el-option>
                    <el-option label="高价值专利要素-获得国家科学技术奖或中国专利奖" value="has_reward"></el-option>
                   
            </el-select>




             <el-select class="inputView" placeholder="--请选择--">
                     <el-option label="是" value="1"></el-option>
                    <el-option label="否" value="0"></el-option>
                   
            </el-select>
             <i @click="addPatentValue" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="!item.hasOwnProperty('notFrist')" class="el-icon-circle-plus-outline"></i>
            <i @click="deltPatentValue(index)" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="item.hasOwnProperty('notFrist')" class="el-icon-remove-outline"></i>
           </div>
           
        </el-form-item>

        <!-- 其他信息 -->

         <el-form-item label="其他信息">
            <div v-for="(item,index) in form.otherInfo" :key="index" class="sysItem">
              <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.boolType"  style="width:80px;margin-right:10px">
                    <el-option label="AND" value=1></el-option>
                    <el-option label="OR" value=2></el-option>
                    <el-option label="NOT" value=3></el-option>
            </el-select>
             <el-select v-if="!item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:300px;margin-bottom:6px">
                    <el-option label="专利类型" value="patent_type"></el-option>
                    <el-option label="专利评分" value="patent_score"></el-option>
                     <el-option label="专利估值(万元)" value="patent_cost"></el-option>
                    <el-option label="维持年限" value="duration"></el-option>
                    
                    

                    
            </el-select>

             <el-select v-if="item.hasOwnProperty('notFrist')" v-model="item.key" placeholder="--请选择--" style="width:210px;margin-bottom:6px">
                     <el-option label="专利类型" value="patent_type"></el-option>
                    <el-option label="专利评分" value="patent_score"></el-option>
                     <el-option label="专利估值(万元)" value="patent_cost"></el-option>
                    <el-option label="维持年限" value="duration"></el-option>
                   
            </el-select>




             <el-select class="inputView" placeholder="--请选择--">
                     <el-option label="是" value="1"></el-option>
                    <el-option label="否" value="0"></el-option>
                   
            </el-select>
             <i @click="addOtherInfo" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="!item.hasOwnProperty('notFrist')" class="el-icon-circle-plus-outline"></i>
            <i @click="deltOtherInfo(index)" style="position:absolute;right:-30px;fontSize:20px;marginTop:5px" v-if="item.hasOwnProperty('notFrist')" class="el-icon-remove-outline"></i>
           </div>
           
        </el-form-item>

        <el-form-item>
            <el-button @click="validateData" type="primary">检索</el-button>
        </el-form-item>




  
        </el-form>
    </div>
</template>
<script>
  import {toRetrieval} from "@/api/retrieval"
  export default {
    data() {
      return {
         
        form: {
            // 号码
            mainInfo:[
                {
                value:"",
                
                },        
            ],
            //名称和地址
            nameAndAddress:[
                {
                    value:""
                }
            ],

            legalInfo:[{
                value:""
            }],

            isLegal:[{
                value:""
            }],

            patentAward:[{
                value:""
            }],

            patentValue:[{
                value:""
            }],

            otherInfo:[{
                value:""
            }],

            dateInfo:{
                value:"",
                sign:"",
                value1:"",
            value2:"",
            },

           

        
            
            
                
            
        },
        pickerOptions: {
          disabledDate(time) {
            return time.getTime() > Date.now();
          },
          shortcuts: [{
            text: '今天',
            onClick(picker) {
              picker.$emit('pick', new Date());
            }
          }, {
            text: '昨天',
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24);
              picker.$emit('pick', date);
            }
          }, {
            text: '一周前',
            onClick(picker) {
              const date = new Date();
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit('pick', date);
            }
          }]
        },
      }
    },
    methods: {
      onSubmit() {
        console.log('submit!');
      },
      addNum(){
          if(this.form.mainInfo.length<4){
              let obj={
                  value:"",
                  notFrist:true,
                  boolType:"1"
              }
              this.form.mainInfo.push(obj)
          }
      },
      deltNum(index){
        //  console.log(index)
         this.form.mainInfo.splice(index, 1);

      },

      addName(){
         if(this.form.nameAndAddress.length<4){
              let obj={
                  value:"",
                  notFrist:true,
                  boolType:"1"
              }
              this.form.nameAndAddress.push(obj)
          }

      },
      deltNameAndAddress(index){
          this.form.nameAndAddress.splice(index, 1);
      },
      addLegal(){
          if(this.form.legalInfo.length<4){
              let obj={
                  value:"",
                  notFrist:true,
                  boolType:"1"
              }
              this.form.legalInfo.push(obj)
          }
      },
      deltLegal(index){
           this.form.legalInfo.splice(index, 1);
      },
      addIsLegal(){
           if(this.form.isLegal.length<4){
              let obj={
                  value:"",
                  notFrist:true,
                  boolType:"1"
              }
              this.form.isLegal.push(obj)
          }
      },
      deltIsLegal(index){
          this.form.isLegal.splice(index, 1);
      },
      addPatentAward(){
          if(this.form.patentAward.length<4){
              let obj={
                  value:"",
                  notFrist:true,
                  boolType:"1"
              }
              this.form.patentAward.push(obj)
          }
      },
      deltPatentAward(index){
           this.form.patentAward.splice(index, 1);
      },
      addPatentValue(){
          if(this.form.patentValue.length<4){
              let obj={
                  value:"",
                  notFrist:true,
                  boolType:"1"
              }
              this.form.patentValue.push(obj)
          }
      },
      deltPatentValue(index){
          this.form.patentValue.splice(index, 1);
      },
      addOtherInfo(){
           if(this.form.patentValue.length<4){
              let obj={
                  value:"",
                  notFrist:true,
                  boolType:"1"
              }
              this.form.otherInfo.push(obj)
          }
      },
      deltOtherInfo(index){
          this.form.otherInfo.splice(index, 1);
          
      },

      validateData(){

          console.log("数据:", this.form)
          toRetrieval(this.form).then(res=>{

          })
          


          
      }

    }
  }
</script>
<style lang="scss" scoped>
   .box{
      width: 60%;
      margin-left: 20%;
      margin-top: 50px;
       .sysItem{
          display: flex;
          flex-direction: row;
          .inputView{
              flex: 1;
              margin-left: 10px;
          }
      }
   }


</style>